package com.rr.learningdemo.controller;

import com.rr.learningdemo.pojo.Person;
import com.rr.learningdemo.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author RR
 * @date 2021/5/16 20:05
 */
@RestController
public class PersonController {
    @Autowired
    private PersonService personService;

    @GetMapping("/getPerson/{id}")
    public Person getPerson(@PathVariable("id") Integer id) {
        return personService.selectById(id);
    }

    @GetMapping("updatePerson")
    public Person updatePerson(Person person) {
        return personService.updateById(person);
    }

    @GetMapping("/deletePerson/{id}")
    public boolean deletePerson(@PathVariable("id") Integer id) {
        return personService.deleteById(id);
    }
}
